<?php
namespace Android\Controller;
use Think\Controller;
class some{

}
class FoundController extends Controller {
    //店铺查找
    public function find(){
        $info=M('Shop');
        $type_id=$_POST['type'];
        $array=[];
        $shopinfo= $info->where('type='.$type_id)->field('shop_id,shop_name,intro')->select();
        foreach ($shopinfo as $key => $value) {
            $shopid=$value['shop_id'];
            $infooo= $info ->join('activity ac on ac.shop_id=shop.shop_id')->field('act_id,theme')->where('shop.shop_id='. $shopid)->order('gene_time')->limit(1)->find();
            $shopinfo[$key][act]=$infooo? $infooo:'';
        }
        $web=M('website');
        $webinfo=$web->where('type='.$type_id)->field('name,intro,hot')->select();
        $art=M('article');
        $artinfo=$art->where('type='.$type_id)->field('art_id,title,content')->select();
        foreach ($artinfo as $key => $value){
            $userid=$value['user_id'];
            $infooo= $art->join('user us on us.user_id=article.user_id')->field('username')->where('article.user_id='.$userid)->select();
            $artinfo[$key][username]=$infooo;
        }
        $array['shop']=$shopinfo;
        $array['web']= $webinfo;
        $array['art']=$artinfo;

        echo json_encode($array);
    }

    //查看店铺详情
    public function findshop(){
        $info=D('shop');
        $shopid=$_POST['shop_id'];
        $infos= $info->shopdetails($shopid);
        echo json_encode($infos);
    }
    //查看收藏的
    public function findCollect(){
        $info=D('follow');
        $user_id=$_POST['user_id'];
        $infos=$info->followdetails($user_id);
        echo json_encode($infos);
    }


}
